<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en">
	<h:head />
	<body>
		<ui:composition template="/rootWeb.xhtml">
	    <ui:define name="header">
	        <title>机台管理</title>
	        <script type="text/javascript">
				//页面载入时注册
	        	jQuery(document).ready(function(){
	        		//鼠标移入
					jQuery("#postTable_data tr").live("mouseover", function() {
					  	jQuery(this).css("background-color","#CCCCCC");
					});
					//鼠标移出
					jQuery("#postTable_data tr").live("mouseout", function() {
					  	jQuery(this).css("background-color","white");
					});
				});
			</script>
			<style type="text/css">
				
			</style>
		</ui:define>
	    <ui:define name="body">
	    	<h:form id="form" prependId="false">
				<p:dataTable id="postTable" value="#{postAction.postList}" var="post" rowKey="#{post}" emptyMessage="没有记录！"
	    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
               			<f:facet name="header">岗位列表</f:facet>
               			<p:column headerText="岗位编码">#{post.postCode}</p:column>
               			<p:column headerText="岗位名称">#{post.postName}</p:column>
               			<p:column headerText="岗位描述">#{post.postDesc}</p:column>
               			<p:column headerText="操作">
			    			<p:commandLink value="修改"  action="#{postAction.setUpdatePost(post)}" update=":form:updatePostDlgID"  oncomplete="updatePostDlg.show()" style="margin-right:5px;color:RED"/>
			    			<p:commandLink value="删除"  action="#{postAction.setUpdatePost(post)}" update=":form:updatePostDlgID"  oncomplete="deletePostDlg.show()" style="margin-right:5px;color:RED"/>
			    		</p:column>
			    		<f:facet name="footer">
							<p:commandButton value="新增" action="#{postAction.addPost}" update=":form:addPostDlgID" oncomplete="addPostDlg.show()"/>
						</f:facet>
               	</p:dataTable>
               	<!-- 删除 -->
				<p:confirmDialog id="deletePostDlgID" message="删除岗位将删除岗位所对应的系统帐户，确认删除岗位吗?"
					header="删除岗位" severity="alert" widgetVar="deletePostDlg">
					<p:commandButton value="确定" update=":form:postTable" action="#{postAction.doDeletepost}"
						oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);deletePostDlg.hide();}"  />
					<p:commandButton value="取消" onclick="deletePostDlg.hide()" type="button" />
				</p:confirmDialog>
               	<!--  新增 -->
               	<p:dialog id="addPostDlgID" header="新增岗位" widgetVar="addPostDlg" modal="true" resizable="false" >
					<p:outputPanel style="width: 100%" >
						<h:panelGrid columns="2">
							<h:outputLabel for="addPostCode" value="岗位编码："/>
							<h:panelGrid columns="2">
								<p:inputText id="addPostCode" value="#{postAction.addPost.postCode}" />
								<H5 style="color:RED;padding: 0px;margin: 0px">岗位编码为登录系统的帐户名，不可修改！</H5>
							</h:panelGrid>
							<h:outputLabel for="addPostName" value="岗位名称："/>
							<p:inputText id="addPostName" value="#{postAction.addPost.postName}" />
				            <h:outputLabel for="addPostRemark" value="岗位描述："/>
							<p:inputTextarea id="addPostRemark" value="#{postAction.addPost.postDesc}" rows="1" autoResize="false" maxlength="300" style="width:430px"/>
						</h:panelGrid>
					</p:outputPanel>
					<f:facet name="footer">
						<p:commandButton value="保存" update=":form:postTable" action="#{postAction.savePost}"
							oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);addPostDlg.hide();}"  />
					</f:facet>
				</p:dialog>
				<!-- 更新 -->
				<p:dialog id="updatePostDlgID" header="修改岗位" widgetVar="updatePostDlg" modal="true" resizable="false" >
					<p:outputPanel style="width: 100%" >
						<h:panelGrid columns="2">
							<h:outputLabel for="updatePostName" value="岗位名称："/>
							<p:inputText id="updatePostName" value="#{postAction.updatePost.postName}" />
				            <h:outputLabel for="updatePostRemark" value="岗位描述："/>
							<p:inputTextarea id="updatePostRemark" value="#{postAction.updatePost.postDesc}" rows="1" autoResize="false" maxlength="300" style="width:430px"/>
						</h:panelGrid>
					</p:outputPanel>
					<f:facet name="footer">
						<p:commandButton value="更新" update=":form:postTable" action="#{postAction.doUpdatePost}"
							oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);updatePostDlg.hide();}"  />
					</f:facet>
				</p:dialog>
				
			</h:form>
	    </ui:define>
		</ui:composition>
	</body>
</html>
